package com.reins.bookstore.object;

import com.reins.bookstore.entity.Book;
import lombok.Data;

import java.math.BigDecimal;

@Data
public class BookRate {
    // 排名
    private Integer Rate;
    // 书本基本信息
    private int bookId;
    private String name;
    private String author;
    private BigDecimal price;
    // 书本总销量
    private Integer sum;
    public BookRate(BookDTO book,Integer sum){
        this.bookId = book.getBookId();
        this.name = book.getName();
        this.author = book.getAuthor();
        this.price = book.getPrice();
        this.sum = sum;
    }
    public BookRate(BasketlineDTO basketlineDTO){
        this.Rate = 0;
        this.bookId = basketlineDTO.getBookId();
        this.name = basketlineDTO.getName();
        this.author = basketlineDTO.getAuthor();
        this.price = basketlineDTO.getPrice();
        this.sum = basketlineDTO.getNum();
    }
    public BookRate(Integer Rate, int bookId, String name, String author, BigDecimal price, Integer sum){
        this.Rate = Rate;
        this.bookId = bookId;
        this.name = name;
        this.author = author;
        this.price = price;
        this.sum = sum;
    }
    public BookRate(Integer Rate, int bookId){
        this.Rate = Rate;
        this.bookId = bookId;
        this.name = "null";
        this.author = "null";
        this.price = new BigDecimal("0.00");
        this.sum = 0;
    }
    public BookRate(BookDTO bookDTO){
        this.Rate = 0;
        this.bookId = bookDTO.getBookId();
        this.name = bookDTO.getName();
        this.author = bookDTO.getAuthor();
        this.price = bookDTO.getPrice();
        this.sum = 1;
    }
    public void addSum(Integer add){
        sum += add;
    }
}

